package com.hdw.med.service;

import com.hdw.common.vo.PaginationVO;
import org.springframework.stereotype.Service;
import com.hdw.med.api.MdMedTblogService;
import com.hdw.med.mapper.MdMedTblogMapper;
import com.hdw.med.bean.model.MdMedTblog;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
import java.util.List;

/**
 * mdMedTblog服务实现类
 * Created by liujunlei on 2021/12/11.
 */
@Service
@Transactional
public class MdMedTblogServiceImpl implements MdMedTblogService{

    private static final Logger LOGGER = LoggerFactory.getLogger(MdMedTblogServiceImpl.class);

    @Autowired
    private MdMedTblogMapper mdMedTblogMapper;

    @Override
    public int insert(MdMedTblog mdMedTblog) {
        return mdMedTblogMapper.insert(mdMedTblog);
    }

    @Override
    public int insertSelective(MdMedTblog mdMedTblog)  {
        return mdMedTblogMapper.insertSelective(mdMedTblog);
    }

    @Override
    public int deleteById(Long idLog)  {
        return mdMedTblogMapper.deleteByPrimaryKey(idLog);
    }

    @Override
    public int updateByIdSelective(MdMedTblog mdMedTblog)  {

        return mdMedTblogMapper.updateByPrimaryKeySelective(mdMedTblog);
    }

    @Override
    public int updateById(MdMedTblog mdMedTblog)  {
        return mdMedTblogMapper.updateByPrimaryKey(mdMedTblog);
    }

    @Override
    public MdMedTblog getById(Long idLog)  {
        return mdMedTblogMapper.selectByPrimaryKey(idLog);
    }

    @Override
    public List<MdMedTblog> findByModel(MdMedTblog mdMedTblog)  {
        return mdMedTblogMapper.findByModel(mdMedTblog);
    }

    @Override
    public PaginationVO<MdMedTblog> findPageByModel(MdMedTblog mdMedTblog, Integer pageNum, Integer pageSize) {
        PageHelper.startPage(pageNum == null? 1 : pageNum, pageSize == null? 10 : pageSize);
        List<MdMedTblog> quesList = mdMedTblogMapper.findByModel(mdMedTblog);
        PageInfo<MdMedTblog> pageInfo = new PageInfo<>(quesList);
        PaginationVO<MdMedTblog> paginationVo = new PaginationVO(pageInfo.getTotal(), pageInfo.getList());
        return paginationVo;
    }

    @Override
    public long insertReturnId(MdMedTblog record) {
        return mdMedTblogMapper.insertReturnId(record);
    }
}
